package com.kvw.filesystem.model;

import lombok.Data;
import lombok.ToString;

import java.io.InputStream;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Desc:
 *
 * @author: keen
 * Date: 2020-07-25
 * Time: 22:32
 */
@Data
@ToString
public class FileObject {
    private String fileId;
    private String fileName;
    private long fileSize;
    private long partSize;
    private InputStream dataSource;
    private String bucket;
    private String sha512;
    private Map<String, String> metadata;

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private FileObject fileObject;

        public Builder() {
            fileObject = new FileObject();
        }

        public Builder fileId(String fileId) {
            fileObject.setFileId(fileId);
            return this;
        }

        public Builder fileName(String fileName) {
            fileObject.setFileName(fileName);
            return this;
        }

        public Builder fileSize(long fileSize) {
            fileObject.setFileSize(fileSize);
            return this;
        }

        public Builder partSize(long partSize) {
            fileObject.setPartSize(partSize);
            return this;
        }

        public Builder dataSource(InputStream dataSource) {
            fileObject.setDataSource(dataSource);
            return this;
        }

        public Builder bucket(String bucket) {
            fileObject.setBucket(bucket);
            return this;
        }

        public Builder sha512(String sha512) {
            fileObject.setSha512(sha512);
            return this;
        }

        public Builder metadata(Map<String, String> metadata) {
            fileObject.setMetadata(metadata);
            return this;
        }

        public FileObject build() {
            return this.fileObject;
        }
    }
}
